<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%String path = request.getContextPath();%>
<html>
<head>
    <title>Title</title>
    <script>
        $(function (){
            $('#testfile').fileinput({
                language: 'zh',    							//汉化
                uploadUrl: '<%=path%>/player/upload',		//上传地址
                maxFileCount : 1,							//最大上传个数
                enctype : "multipart/form-data",			//预览
                maxFileSize : 10240,						//设置上传文件的大小
                allowedFileExtensions : ["gif", "jpeg", "jpg", "bmp", "png"],//限制上传类型
                browseClass: 'btn btn-primary',
                ErrMsg: "文件错误,图片类型必须是(gif,jpeg,jpg,bmp,png)中的一种",
                //下面几个就是初始化预览图片的配置
                initialPreviewAsData: true,//是否初始预览图片
                initialPreviewFileType: 'image',//回显文件类型（初始预览文件类型）
                initialPreview: "${playerData.playerImg}",
            });

            //获取阿里云传回来的值
            $("#testfile").on("fileuploaded", function(event, data, previewId, index){
                var imgUrl = data.response.data;
                $("#playerImg").val(imgUrl);
            })
        })
    </script>
</head>
<body>
    <form role="form" id="user_update_form">
        <input type="hidden" name="playerId" value="${playerData.playerId}">
        <div class="form-group">
            <label for="playerName">玩家名:</label>
            <input type="text" class="form-control" id="playerName" name="playerName" placeholder="玩家名" value="${playerData.playerName}">
        </div>

        <div class="form-group">
            <label for="playerName">玩家账号:</label>
            <input type="text" readonly="readonly" class="form-control" id="playerAccount" name="playerAccount" placeholder="玩家账号" value="${playerData.playerAccount}">
        </div>

        <div class="form-group">
            <label for="playerScore">玩家分值:</label>
            <input type="text" class="form-control" id="playerScore" name="playerScore" placeholder="玩家分值" value="${playerData.playerScore}">
        </div>

        <div class="form-group">
            <label for="playerScore">玩家权限:</label>
            <select name="positionId">
                <option value="-1">请选择</option>
                <c:forEach items="${position}" var="p">
                    <option value="${p.positionId}" <c:if test="${playerData.positionId == p.positionId}">selected</c:if>>${p.positionName}</option>
                </c:forEach>
            </select>
        </div>

        <div class="form-group">
            <label>所属游戏:</label>
            <select name="games">
                <option value="-1">请选择</option>
                <c:forEach items="${games}" var="g">
                    <option value="${g.gameId}" <c:if test="${playerData.games == g.gameId}">selected</c:if>>${g.gameName}</option>
                </c:forEach>
            </select>
        </div>

        <div class="form-group" style="width:300px;height:300px">
            <label for="testfile">玩家头像:</label>
            <input type="file"  id="testfile" name="image" multiple >
            <input type="hidden" name="playerImg" id="playerImg" value="${playerData.playerImg}">
        </div>

    </form>
</body>
</html>
